# app/__init__.py
from flask import Flask
from flask_cors import CORS
from config import data

from init.celery_init import init_celery


def create_app():
    app = Flask(__name__)
    app.config.from_mapping(
        CELERY=dict(
            broker_url=data["celery"]["broker"],
            result_backend=data["celery"]["backend"],
        )
    )
    from app.routes import admin_bp
    app.register_blueprint(admin_bp)

    init_celery(app)
    CORS(app, resource=r"/*", supports_credentials=True)
    return app
